 Imports MySql.Data.MySqlClient 
 Imports System.Data.OleDb
Imports System.Data.SqlClient
 Imports System .Data .SqlServerCe 
 Imports System.Data.OracleClient 
Imports System.Data
Imports DTO
Public Class CTPHIEUTHUDao
Inherits AbstractDao
 #Region "New" 
 Public Sub New(ByVal connection As KetNoiDto)
 MyBase.New(connection)
 End Sub
 Public Sub New( ByVal IDCTPHIEUTHU As System.Int32, ByVal connection As KetNoiDto)
 MyBase.New("CTPHIEUTHU", "select * from CTPHIEUTHU where IDCTPHIEUTHU=" & IDCTPHIEUTHU & "", connection)
 End Sub
 #End Region 
 Public Sub Them(ByVal Dto As CTPHIEUTHUDto)
 Dim strsql As String
 strsql = "Insert into CTPHIEUTHU(MAPHIEUTHU,IDPHIEUTHU,NGUOITHU,NGUOILAPPHIEU,SOTIENTHU,TRANGTHAI,GHICHU) values (?,?,?,?,?,?,?)
 Moketnoi()
 select case ketnoi.MSsql 
 Case Class_KieuDL.Access
 Dim cmd As New OleDbCommand(strsql, Ket_noi_access)
cmd.Parameters.Add("@MAPHIEUTHU", OleDbType.VarWChar)
cmd.Parameters.Add("@IDPHIEUTHU", OleDbType.Integer)
cmd.Parameters.Add("@NGUOITHU", OleDbType.Integer)
cmd.Parameters.Add("@NGUOILAPPHIEU", OleDbType.Integer)
cmd.Parameters.Add("@SOTIENTHU", OleDbType.Integer)
cmd.Parameters.Add("@TRANGTHAI", OleDbType.Integer)
cmd.Parameters.Add("@GHICHU", OleDbType.VarWChar)
cmd.Parameters("@MAPHIEUTHU").Value = Dto.MAPHIEUTHU
cmd.Parameters("@IDPHIEUTHU").Value = Dto.IDPHIEUTHU
cmd.Parameters("@NGUOITHU").Value = Dto.NGUOITHU
cmd.Parameters("@NGUOILAPPHIEU").Value = Dto.NGUOILAPPHIEU
cmd.Parameters("@SOTIENTHU").Value = Dto.SOTIENTHU
cmd.Parameters("@TRANGTHAI").Value = Dto.TRANGTHAI
cmd.Parameters("@GHICHU").Value = Dto.GHICHU
 cmd.ExecuteNonQuery()
 strsql = "Select @@IDENTITY"
 cmd = New OleDbCommand(strsql, Ket_noi_access)
 Dto.IDCTPHIEUTHU = cmd.ExecuteScalar()
 Case Class_KieuDL.Sql,Class_KieuDL.sqlExpress
 strsql = "Insert into CTPHIEUTHU(MAPHIEUTHU,IDPHIEUTHU,NGUOITHU,NGUOILAPPHIEU,SOTIENTHU,TRANGTHAI,GHICHU) values (@MAPHIEUTHU,@IDPHIEUTHU,@NGUOITHU,@NGUOILAPPHIEU,@SOTIENTHU,@TRANGTHAI,@GHICHU)
 Dim cmd As New sqlCommand(strsql, Ket_noi_sql)
cmd.Parameters.Add("@MAPHIEUTHU", SqlDbType.NVarChar)
cmd.Parameters.Add("@IDPHIEUTHU", SqlDbType.Int)
cmd.Parameters.Add("@NGUOITHU", SqlDbType.Int)
cmd.Parameters.Add("@NGUOILAPPHIEU", SqlDbType.Int)
cmd.Parameters.Add("@SOTIENTHU", SqlDbType.Int)
cmd.Parameters.Add("@TRANGTHAI", SqlDbType.Int)
cmd.Parameters.Add("@GHICHU", SqlDbType.NVarChar)
cmd.Parameters("@MAPHIEUTHU").Value = Dto.MAPHIEUTHU
cmd.Parameters("@IDPHIEUTHU").Value = Dto.IDPHIEUTHU
cmd.Parameters("@NGUOITHU").Value = Dto.NGUOITHU
cmd.Parameters("@NGUOILAPPHIEU").Value = Dto.NGUOILAPPHIEU
cmd.Parameters("@SOTIENTHU").Value = Dto.SOTIENTHU
cmd.Parameters("@TRANGTHAI").Value = Dto.TRANGTHAI
cmd.Parameters("@GHICHU").Value = Dto.GHICHU
 cmd.ExecuteNonQuery()
 strsql = "Select @@IDENTITY"
 cmd = New sqlCommand(strsql, Ket_noi_sql)
 Dto.IDCTPHIEUTHU = cmd.ExecuteScalar()
 Case Class_KieuDL.SqlCe
 strsql = "Insert into CTPHIEUTHU(MAPHIEUTHU,IDPHIEUTHU,NGUOITHU,NGUOILAPPHIEU,SOTIENTHU,TRANGTHAI,GHICHU) values (@MAPHIEUTHU,@IDPHIEUTHU,@NGUOITHU,@NGUOILAPPHIEU,@SOTIENTHU,@TRANGTHAI,@GHICHU)
 Dim cmd As New sqlceCommand(strsql, Ket_noi_SqlCe)
cmd.Parameters("@MAPHIEUTHU").Value = Dto.MAPHIEUTHU
cmd.Parameters("@IDPHIEUTHU").Value = Dto.IDPHIEUTHU
cmd.Parameters("@NGUOITHU").Value = Dto.NGUOITHU
cmd.Parameters("@NGUOILAPPHIEU").Value = Dto.NGUOILAPPHIEU
cmd.Parameters("@SOTIENTHU").Value = Dto.SOTIENTHU
cmd.Parameters("@TRANGTHAI").Value = Dto.TRANGTHAI
cmd.Parameters("@GHICHU").Value = Dto.GHICHU
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.Oracle
 strsql = "Insert into CTPHIEUTHU(MAPHIEUTHU,IDPHIEUTHU,NGUOITHU,NGUOILAPPHIEU,SOTIENTHU,TRANGTHAI,GHICHU) values (@MAPHIEUTHU,@IDPHIEUTHU,@NGUOITHU,@NGUOILAPPHIEU,@SOTIENTHU,@TRANGTHAI,@GHICHU)
 Dim cmd As New OracleCommand(strsql, Ket_noi_Oracle)
cmd.Parameters("@MAPHIEUTHU").Value = Dto.MAPHIEUTHU
cmd.Parameters("@IDPHIEUTHU").Value = Dto.IDPHIEUTHU
cmd.Parameters("@NGUOITHU").Value = Dto.NGUOITHU
cmd.Parameters("@NGUOILAPPHIEU").Value = Dto.NGUOILAPPHIEU
cmd.Parameters("@SOTIENTHU").Value = Dto.SOTIENTHU
cmd.Parameters("@TRANGTHAI").Value = Dto.TRANGTHAI
cmd.Parameters("@GHICHU").Value = Dto.GHICHU
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.Mysql
 strsql = "Insert into CTPHIEUTHU(MAPHIEUTHU,IDPHIEUTHU,NGUOITHU,NGUOILAPPHIEU,SOTIENTHU,TRANGTHAI,GHICHU) values (@MAPHIEUTHU,@IDPHIEUTHU,@NGUOITHU,@NGUOILAPPHIEU,@SOTIENTHU,@TRANGTHAI,@GHICHU)
 Dim cmd As New MySqlCommand(strsql, Ket_noi_MySql)
cmd.Parameters.Add("@MAPHIEUTHU", MySqlDbType.String)
cmd.Parameters.Add("@IDPHIEUTHU", MySqlDbType.Int32)
cmd.Parameters.Add("@NGUOITHU", MySqlDbType.Int32)
cmd.Parameters.Add("@NGUOILAPPHIEU", MySqlDbType.Int32)
cmd.Parameters.Add("@SOTIENTHU", MySqlDbType.Int32)
cmd.Parameters.Add("@TRANGTHAI", MySqlDbType.Int32)
cmd.Parameters.Add("@GHICHU", MySqlDbType.String)
cmd.Parameters("@MAPHIEUTHU").Value = Dto.MAPHIEUTHU
cmd.Parameters("@IDPHIEUTHU").Value = Dto.IDPHIEUTHU
cmd.Parameters("@NGUOITHU").Value = Dto.NGUOITHU
cmd.Parameters("@NGUOILAPPHIEU").Value = Dto.NGUOILAPPHIEU
cmd.Parameters("@SOTIENTHU").Value = Dto.SOTIENTHU
cmd.Parameters("@TRANGTHAI").Value = Dto.TRANGTHAI
cmd.Parameters("@GHICHU").Value = Dto.GHICHU
 cmd.ExecuteNonQuery()
 End Select
 Ngatketnoi()
 End Sub
 Public Sub Xoa( ByVal IDCTPHIEUTHU As System.Int32 )
 Dim strSQL As String
 Moketnoi()
 select case ketnoi.MSsql 
 Case Class_KieuDL.Access
strSQL = "Delete From CTPHIEUTHU Where IDCTPHIEUTHU= ? 
Dim cmd As New OleDbCommand(strSQL, Ket_noi_access)
cmd.Parameters.Add("@IDCTPHIEUTHU",OleDbType.Integer).Value = IDCTPHIEUTHU
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.Sql,Class_KieuDL.sqlExpress 
strSQL = "Delete From CTPHIEUTHU Where IDCTPHIEUTHU= @IDCTPHIEUTHU
Dim cmd As New sqlCommand(strSQL, Ket_noi_sql)
cmd.Parameters.Add("@IDCTPHIEUTHU",SqlDbType.Int).value=IDCTPHIEUTHU
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.SqlCe
strSQL = "Delete From CTPHIEUTHU Where IDCTPHIEUTHU=" & IDCTPHIEUTHU & "
 Dim cmd As New SqlCeCommand(strSQL, Ket_noi_SqlCe)
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.Oracle
strSQL = "Delete From CTPHIEUTHU Where IDCTPHIEUTHU=" & IDCTPHIEUTHU & "
 Dim cmd As New OracleCommand(strSQL, Ket_noi_Oracle)
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.MySql
strSQL = "Delete From CTPHIEUTHU Where IDCTPHIEUTHU=" & IDCTPHIEUTHU & "
 Dim cmd As New MySqlCommand(strSQL, Ket_noi_MySql)
 cmd.ExecuteNonQuery()
 End Select
 Ngatketnoi()
 End Sub
 Public Sub sua(ByVal dto As CTPHIEUTHUDto)
 Dim strSQL As String
 Moketnoi()
 select case ketnoi.MSsql 
 Case Class_KieuDL.Access
 strSQL = "Update CTPHIEUTHU Set MAPHIEUTHU=? ,IDPHIEUTHU=? ,NGUOITHU=? ,NGUOILAPPHIEU=? ,SOTIENTHU=? ,TRANGTHAI=? ,GHICHU= ? where IDCTPHIEUTHU= ? "
 Dim cmd As New OleDbCommand(strSQL, Ket_noi_access)
cmd.Parameters.Add("@MAPHIEUTHU", OleDbType.VarWChar)
cmd.Parameters.Add("@IDPHIEUTHU", OleDbType.Integer)
cmd.Parameters.Add("@NGUOITHU", OleDbType.Integer)
cmd.Parameters.Add("@NGUOILAPPHIEU", OleDbType.Integer)
cmd.Parameters.Add("@SOTIENTHU", OleDbType.Integer)
cmd.Parameters.Add("@TRANGTHAI", OleDbType.Integer)
cmd.Parameters.Add("@GHICHU", OleDbType.VarWChar)
cmd.Parameters.Add("@IDCTPHIEUTHU", OleDbType.Integer)
cmd.Parameters("@MAPHIEUTHU").Value = dto.MAPHIEUTHU
cmd.Parameters("@IDPHIEUTHU").Value = dto.IDPHIEUTHU
cmd.Parameters("@NGUOITHU").Value = dto.NGUOITHU
cmd.Parameters("@NGUOILAPPHIEU").Value = dto.NGUOILAPPHIEU
cmd.Parameters("@SOTIENTHU").Value = dto.SOTIENTHU
cmd.Parameters("@TRANGTHAI").Value = dto.TRANGTHAI
cmd.Parameters("@GHICHU").Value = dto.GHICHU
cmd.Parameters("@IDCTPHIEUTHU").Value = dto.IDCTPHIEUTHU
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.Sql,Class_KieuDL.sqlExpress 
 strSQL = "Update CTPHIEUTHU Set MAPHIEUTHU= @MAPHIEUTHU , IDPHIEUTHU= @IDPHIEUTHU , NGUOITHU= @NGUOITHU , NGUOILAPPHIEU= @NGUOILAPPHIEU , SOTIENTHU= @SOTIENTHU , TRANGTHAI= @TRANGTHAI , GHICHU= @GHICHU where IDCTPHIEUTHU= @IDCTPHIEUTHU"
 Dim cmd As New sqlCommand(strSQL, Ket_noi_sql)
cmd.Parameters.Add("@MAPHIEUTHU", SqlDbType.NVarChar)
cmd.Parameters.Add("@IDPHIEUTHU", SqlDbType.Int)
cmd.Parameters.Add("@NGUOITHU", SqlDbType.Int)
cmd.Parameters.Add("@NGUOILAPPHIEU", SqlDbType.Int)
cmd.Parameters.Add("@SOTIENTHU", SqlDbType.Int)
cmd.Parameters.Add("@TRANGTHAI", SqlDbType.Int)
cmd.Parameters.Add("@GHICHU", SqlDbType.NVarChar)
cmd.Parameters.Add("@IDCTPHIEUTHU", SqlDbType.Int)
cmd.Parameters("@MAPHIEUTHU").Value = dto.MAPHIEUTHU
cmd.Parameters("@IDPHIEUTHU").Value = dto.IDPHIEUTHU
cmd.Parameters("@NGUOITHU").Value = dto.NGUOITHU
cmd.Parameters("@NGUOILAPPHIEU").Value = dto.NGUOILAPPHIEU
cmd.Parameters("@SOTIENTHU").Value = dto.SOTIENTHU
cmd.Parameters("@TRANGTHAI").Value = dto.TRANGTHAI
cmd.Parameters("@GHICHU").Value = dto.GHICHU
cmd.Parameters("@IDCTPHIEUTHU").Value = dto.IDCTPHIEUTHU
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.SqlCe
 strSQL = "Update CTPHIEUTHU Set MAPHIEUTHU= @MAPHIEUTHU , IDPHIEUTHU= @IDPHIEUTHU , NGUOITHU= @NGUOITHU , NGUOILAPPHIEU= @NGUOILAPPHIEU , SOTIENTHU= @SOTIENTHU , TRANGTHAI= @TRANGTHAI , GHICHU= @GHICHU where IDCTPHIEUTHU= @IDCTPHIEUTHU"
 Dim cmd As New SqlCeCommand(strSQL, Ket_noi_SqlCe)
cmd.Parameters("@MAPHIEUTHU").Value = dto.MAPHIEUTHU
cmd.Parameters("@IDPHIEUTHU").Value = dto.IDPHIEUTHU
cmd.Parameters("@NGUOITHU").Value = dto.NGUOITHU
cmd.Parameters("@NGUOILAPPHIEU").Value = dto.NGUOILAPPHIEU
cmd.Parameters("@SOTIENTHU").Value = dto.SOTIENTHU
cmd.Parameters("@TRANGTHAI").Value = dto.TRANGTHAI
cmd.Parameters("@GHICHU").Value = dto.GHICHU
cmd.Parameters("@IDCTPHIEUTHU").Value = dto.IDCTPHIEUTHU
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.Oracle
 strSQL = "Update CTPHIEUTHU Set MAPHIEUTHU= @MAPHIEUTHU , IDPHIEUTHU= @IDPHIEUTHU , NGUOITHU= @NGUOITHU , NGUOILAPPHIEU= @NGUOILAPPHIEU , SOTIENTHU= @SOTIENTHU , TRANGTHAI= @TRANGTHAI , GHICHU= @GHICHU where IDCTPHIEUTHU= @IDCTPHIEUTHU"
 Dim cmd As New OracleCommand(strSQL, Ket_noi_Oracle)
cmd.Parameters("@MAPHIEUTHU").Value = dto.MAPHIEUTHU
cmd.Parameters("@IDPHIEUTHU").Value = dto.IDPHIEUTHU
cmd.Parameters("@NGUOITHU").Value = dto.NGUOITHU
cmd.Parameters("@NGUOILAPPHIEU").Value = dto.NGUOILAPPHIEU
cmd.Parameters("@SOTIENTHU").Value = dto.SOTIENTHU
cmd.Parameters("@TRANGTHAI").Value = dto.TRANGTHAI
cmd.Parameters("@GHICHU").Value = dto.GHICHU
cmd.Parameters("@IDCTPHIEUTHU").Value = dto.IDCTPHIEUTHU
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.MySql
 strSQL = "Update CTPHIEUTHU Set MAPHIEUTHU= @MAPHIEUTHU , IDPHIEUTHU= @IDPHIEUTHU , NGUOITHU= @NGUOITHU , NGUOILAPPHIEU= @NGUOILAPPHIEU , SOTIENTHU= @SOTIENTHU , TRANGTHAI= @TRANGTHAI , GHICHU= @GHICHU where IDCTPHIEUTHU= @IDCTPHIEUTHU"
 Dim cmd As New MySqlCommand(strSQL, Ket_noi_MySql)
cmd.Parameters.Add("@MAPHIEUTHU", MySqlDbType.String)
cmd.Parameters.Add("@IDPHIEUTHU", MySqlDbType.Int32)
cmd.Parameters.Add("@NGUOITHU", MySqlDbType.Int32)
cmd.Parameters.Add("@NGUOILAPPHIEU", MySqlDbType.Int32)
cmd.Parameters.Add("@SOTIENTHU", MySqlDbType.Int32)
cmd.Parameters.Add("@TRANGTHAI", MySqlDbType.Int32)
cmd.Parameters.Add("@GHICHU", MySqlDbType.String)
cmd.Parameters.Add("@IDCTPHIEUTHU", MySqlDbType.Int32)
cmd.Parameters("@MAPHIEUTHU").Value = dto.MAPHIEUTHU
cmd.Parameters("@IDPHIEUTHU").Value = dto.IDPHIEUTHU
cmd.Parameters("@NGUOITHU").Value = dto.NGUOITHU
cmd.Parameters("@NGUOILAPPHIEU").Value = dto.NGUOILAPPHIEU
cmd.Parameters("@SOTIENTHU").Value = dto.SOTIENTHU
cmd.Parameters("@TRANGTHAI").Value = dto.TRANGTHAI
cmd.Parameters("@GHICHU").Value = dto.GHICHU
cmd.Parameters("@IDCTPHIEUTHU").Value = dto.IDCTPHIEUTHU
 cmd.ExecuteNonQuery()
 End Select
 Ngatketnoi()
 End Sub
 Public Sub SuaMAPHIEUTHU( ByVal MAPHIEUTHU as System.String, ByVal IDCTPHIEUTHU As System.Int32 )
 Dim strSQL As String
 Moketnoi()
 select case ketnoi.MSsql 
 Case Class_KieuDL.Access
 strSQL = "Update CTPHIEUTHU Set MAPHIEUTHU = ?  where IDCTPHIEUTHU= ? "
 Dim cmd As New OleDbCommand(strSQL, Ket_noi_access)
 cmd.Parameters.Add("@MAPHIEUTHU", OleDbType.VarWChar)
 cmd.Parameters.Add("@IDCTPHIEUTHU", OleDbType.Integer)
 cmd.Parameters("@MAPHIEUTHU").Value =  MAPHIEUTHU
cmd.Parameters("@IDCTPHIEUTHU").Value =  IDCTPHIEUTHU
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.Sql,Class_KieuDL.sqlExpress 
 strSQL = "Update CTPHIEUTHU Set MAPHIEUTHU = @MAPHIEUTHU  where IDCTPHIEUTHU= @IDCTPHIEUTHU"
 Dim cmd As New sqlCommand(strSQL, Ket_noi_sql)
 cmd.Parameters.Add("@MAPHIEUTHU", SqlDbType.NVarChar)
 cmd.Parameters.Add("@IDCTPHIEUTHU", SqlDbType.Int)
 cmd.Parameters("@MAPHIEUTHU").Value =  MAPHIEUTHU
cmd.Parameters("@IDCTPHIEUTHU").Value =  IDCTPHIEUTHU
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.SqlCe
 strSQL = "Update CTPHIEUTHU Set MAPHIEUTHU =" & MAPHIEUTHU & "  where IDCTPHIEUTHU=" & IDCTPHIEUTHU & ""
 Dim cmd As New SqlCeCommand(strSQL, Ket_noi_SqlCe)
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.Oracle
 strSQL = "Update CTPHIEUTHU Set MAPHIEUTHU =" & MAPHIEUTHU & "  where IDCTPHIEUTHU=" & IDCTPHIEUTHU & ""
 Dim cmd As New OracleCommand(strSQL, Ket_noi_Oracle)
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.MySql
 strSQL = "Update CTPHIEUTHU Set MAPHIEUTHU =" & MAPHIEUTHU & "  where IDCTPHIEUTHU=" & IDCTPHIEUTHU & ""
 Dim cmd As New MySqlCommand(strSQL, Ket_noi_MySql)
 cmd.ExecuteNonQuery()
 End Select 
 Ngatketnoi()
 End Sub
 Public Sub SuaIDPHIEUTHU( ByVal IDPHIEUTHU as System.Int32, ByVal IDCTPHIEUTHU As System.Int32 )
 Dim strSQL As String
 Moketnoi()
 select case ketnoi.MSsql 
 Case Class_KieuDL.Access
 strSQL = "Update CTPHIEUTHU Set IDPHIEUTHU = ?  where IDCTPHIEUTHU= ? "
 Dim cmd As New OleDbCommand(strSQL, Ket_noi_access)
 cmd.Parameters.Add("@IDPHIEUTHU", OleDbType.Integer)
 cmd.Parameters.Add("@IDCTPHIEUTHU", OleDbType.Integer)
 cmd.Parameters("@IDPHIEUTHU").Value =  IDPHIEUTHU
cmd.Parameters("@IDCTPHIEUTHU").Value =  IDCTPHIEUTHU
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.Sql,Class_KieuDL.sqlExpress 
 strSQL = "Update CTPHIEUTHU Set IDPHIEUTHU = @IDPHIEUTHU  where IDCTPHIEUTHU= @IDCTPHIEUTHU"
 Dim cmd As New sqlCommand(strSQL, Ket_noi_sql)
 cmd.Parameters.Add("@IDPHIEUTHU", SqlDbType.Int)
 cmd.Parameters.Add("@IDCTPHIEUTHU", SqlDbType.Int)
 cmd.Parameters("@IDPHIEUTHU").Value =  IDPHIEUTHU
cmd.Parameters("@IDCTPHIEUTHU").Value =  IDCTPHIEUTHU
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.SqlCe
 strSQL = "Update CTPHIEUTHU Set IDPHIEUTHU =" & IDPHIEUTHU & "  where IDCTPHIEUTHU=" & IDCTPHIEUTHU & ""
 Dim cmd As New SqlCeCommand(strSQL, Ket_noi_SqlCe)
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.Oracle
 strSQL = "Update CTPHIEUTHU Set IDPHIEUTHU =" & IDPHIEUTHU & "  where IDCTPHIEUTHU=" & IDCTPHIEUTHU & ""
 Dim cmd As New OracleCommand(strSQL, Ket_noi_Oracle)
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.MySql
 strSQL = "Update CTPHIEUTHU Set IDPHIEUTHU =" & IDPHIEUTHU & "  where IDCTPHIEUTHU=" & IDCTPHIEUTHU & ""
 Dim cmd As New MySqlCommand(strSQL, Ket_noi_MySql)
 cmd.ExecuteNonQuery()
 End Select 
 Ngatketnoi()
 End Sub
 Public Sub SuaNGUOITHU( ByVal NGUOITHU as System.Int32, ByVal IDCTPHIEUTHU As System.Int32 )
 Dim strSQL As String
 Moketnoi()
 select case ketnoi.MSsql 
 Case Class_KieuDL.Access
 strSQL = "Update CTPHIEUTHU Set NGUOITHU = ?  where IDCTPHIEUTHU= ? "
 Dim cmd As New OleDbCommand(strSQL, Ket_noi_access)
 cmd.Parameters.Add("@NGUOITHU", OleDbType.Integer)
 cmd.Parameters.Add("@IDCTPHIEUTHU", OleDbType.Integer)
 cmd.Parameters("@NGUOITHU").Value =  NGUOITHU
cmd.Parameters("@IDCTPHIEUTHU").Value =  IDCTPHIEUTHU
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.Sql,Class_KieuDL.sqlExpress 
 strSQL = "Update CTPHIEUTHU Set NGUOITHU = @NGUOITHU  where IDCTPHIEUTHU= @IDCTPHIEUTHU"
 Dim cmd As New sqlCommand(strSQL, Ket_noi_sql)
 cmd.Parameters.Add("@NGUOITHU", SqlDbType.Int)
 cmd.Parameters.Add("@IDCTPHIEUTHU", SqlDbType.Int)
 cmd.Parameters("@NGUOITHU").Value =  NGUOITHU
cmd.Parameters("@IDCTPHIEUTHU").Value =  IDCTPHIEUTHU
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.SqlCe
 strSQL = "Update CTPHIEUTHU Set NGUOITHU =" & NGUOITHU & "  where IDCTPHIEUTHU=" & IDCTPHIEUTHU & ""
 Dim cmd As New SqlCeCommand(strSQL, Ket_noi_SqlCe)
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.Oracle
 strSQL = "Update CTPHIEUTHU Set NGUOITHU =" & NGUOITHU & "  where IDCTPHIEUTHU=" & IDCTPHIEUTHU & ""
 Dim cmd As New OracleCommand(strSQL, Ket_noi_Oracle)
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.MySql
 strSQL = "Update CTPHIEUTHU Set NGUOITHU =" & NGUOITHU & "  where IDCTPHIEUTHU=" & IDCTPHIEUTHU & ""
 Dim cmd As New MySqlCommand(strSQL, Ket_noi_MySql)
 cmd.ExecuteNonQuery()
 End Select 
 Ngatketnoi()
 End Sub
 Public Sub SuaNGUOILAPPHIEU( ByVal NGUOILAPPHIEU as System.Int32, ByVal IDCTPHIEUTHU As System.Int32 )
 Dim strSQL As String
 Moketnoi()
 select case ketnoi.MSsql 
 Case Class_KieuDL.Access
 strSQL = "Update CTPHIEUTHU Set NGUOILAPPHIEU = ?  where IDCTPHIEUTHU= ? "
 Dim cmd As New OleDbCommand(strSQL, Ket_noi_access)
 cmd.Parameters.Add("@NGUOILAPPHIEU", OleDbType.Integer)
 cmd.Parameters.Add("@IDCTPHIEUTHU", OleDbType.Integer)
 cmd.Parameters("@NGUOILAPPHIEU").Value =  NGUOILAPPHIEU
cmd.Parameters("@IDCTPHIEUTHU").Value =  IDCTPHIEUTHU
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.Sql,Class_KieuDL.sqlExpress 
 strSQL = "Update CTPHIEUTHU Set NGUOILAPPHIEU = @NGUOILAPPHIEU  where IDCTPHIEUTHU= @IDCTPHIEUTHU"
 Dim cmd As New sqlCommand(strSQL, Ket_noi_sql)
 cmd.Parameters.Add("@NGUOILAPPHIEU", SqlDbType.Int)
 cmd.Parameters.Add("@IDCTPHIEUTHU", SqlDbType.Int)
 cmd.Parameters("@NGUOILAPPHIEU").Value =  NGUOILAPPHIEU
cmd.Parameters("@IDCTPHIEUTHU").Value =  IDCTPHIEUTHU
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.SqlCe
 strSQL = "Update CTPHIEUTHU Set NGUOILAPPHIEU =" & NGUOILAPPHIEU & "  where IDCTPHIEUTHU=" & IDCTPHIEUTHU & ""
 Dim cmd As New SqlCeCommand(strSQL, Ket_noi_SqlCe)
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.Oracle
 strSQL = "Update CTPHIEUTHU Set NGUOILAPPHIEU =" & NGUOILAPPHIEU & "  where IDCTPHIEUTHU=" & IDCTPHIEUTHU & ""
 Dim cmd As New OracleCommand(strSQL, Ket_noi_Oracle)
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.MySql
 strSQL = "Update CTPHIEUTHU Set NGUOILAPPHIEU =" & NGUOILAPPHIEU & "  where IDCTPHIEUTHU=" & IDCTPHIEUTHU & ""
 Dim cmd As New MySqlCommand(strSQL, Ket_noi_MySql)
 cmd.ExecuteNonQuery()
 End Select 
 Ngatketnoi()
 End Sub
 Public Sub SuaSOTIENTHU( ByVal SOTIENTHU as System.Int32, ByVal IDCTPHIEUTHU As System.Int32 )
 Dim strSQL As String
 Moketnoi()
 select case ketnoi.MSsql 
 Case Class_KieuDL.Access
 strSQL = "Update CTPHIEUTHU Set SOTIENTHU = ?  where IDCTPHIEUTHU= ? "
 Dim cmd As New OleDbCommand(strSQL, Ket_noi_access)
 cmd.Parameters.Add("@SOTIENTHU", OleDbType.Integer)
 cmd.Parameters.Add("@IDCTPHIEUTHU", OleDbType.Integer)
 cmd.Parameters("@SOTIENTHU").Value =  SOTIENTHU
cmd.Parameters("@IDCTPHIEUTHU").Value =  IDCTPHIEUTHU
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.Sql,Class_KieuDL.sqlExpress 
 strSQL = "Update CTPHIEUTHU Set SOTIENTHU = @SOTIENTHU  where IDCTPHIEUTHU= @IDCTPHIEUTHU"
 Dim cmd As New sqlCommand(strSQL, Ket_noi_sql)
 cmd.Parameters.Add("@SOTIENTHU", SqlDbType.Int)
 cmd.Parameters.Add("@IDCTPHIEUTHU", SqlDbType.Int)
 cmd.Parameters("@SOTIENTHU").Value =  SOTIENTHU
cmd.Parameters("@IDCTPHIEUTHU").Value =  IDCTPHIEUTHU
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.SqlCe
 strSQL = "Update CTPHIEUTHU Set SOTIENTHU =" & SOTIENTHU & "  where IDCTPHIEUTHU=" & IDCTPHIEUTHU & ""
 Dim cmd As New SqlCeCommand(strSQL, Ket_noi_SqlCe)
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.Oracle
 strSQL = "Update CTPHIEUTHU Set SOTIENTHU =" & SOTIENTHU & "  where IDCTPHIEUTHU=" & IDCTPHIEUTHU & ""
 Dim cmd As New OracleCommand(strSQL, Ket_noi_Oracle)
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.MySql
 strSQL = "Update CTPHIEUTHU Set SOTIENTHU =" & SOTIENTHU & "  where IDCTPHIEUTHU=" & IDCTPHIEUTHU & ""
 Dim cmd As New MySqlCommand(strSQL, Ket_noi_MySql)
 cmd.ExecuteNonQuery()
 End Select 
 Ngatketnoi()
 End Sub
 Public Sub SuaTRANGTHAI( ByVal TRANGTHAI as System.Int32, ByVal IDCTPHIEUTHU As System.Int32 )
 Dim strSQL As String
 Moketnoi()
 select case ketnoi.MSsql 
 Case Class_KieuDL.Access
 strSQL = "Update CTPHIEUTHU Set TRANGTHAI = ?  where IDCTPHIEUTHU= ? "
 Dim cmd As New OleDbCommand(strSQL, Ket_noi_access)
 cmd.Parameters.Add("@TRANGTHAI", OleDbType.Integer)
 cmd.Parameters.Add("@IDCTPHIEUTHU", OleDbType.Integer)
 cmd.Parameters("@TRANGTHAI").Value =  TRANGTHAI
cmd.Parameters("@IDCTPHIEUTHU").Value =  IDCTPHIEUTHU
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.Sql,Class_KieuDL.sqlExpress 
 strSQL = "Update CTPHIEUTHU Set TRANGTHAI = @TRANGTHAI  where IDCTPHIEUTHU= @IDCTPHIEUTHU"
 Dim cmd As New sqlCommand(strSQL, Ket_noi_sql)
 cmd.Parameters.Add("@TRANGTHAI", SqlDbType.Int)
 cmd.Parameters.Add("@IDCTPHIEUTHU", SqlDbType.Int)
 cmd.Parameters("@TRANGTHAI").Value =  TRANGTHAI
cmd.Parameters("@IDCTPHIEUTHU").Value =  IDCTPHIEUTHU
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.SqlCe
 strSQL = "Update CTPHIEUTHU Set TRANGTHAI =" & TRANGTHAI & "  where IDCTPHIEUTHU=" & IDCTPHIEUTHU & ""
 Dim cmd As New SqlCeCommand(strSQL, Ket_noi_SqlCe)
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.Oracle
 strSQL = "Update CTPHIEUTHU Set TRANGTHAI =" & TRANGTHAI & "  where IDCTPHIEUTHU=" & IDCTPHIEUTHU & ""
 Dim cmd As New OracleCommand(strSQL, Ket_noi_Oracle)
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.MySql
 strSQL = "Update CTPHIEUTHU Set TRANGTHAI =" & TRANGTHAI & "  where IDCTPHIEUTHU=" & IDCTPHIEUTHU & ""
 Dim cmd As New MySqlCommand(strSQL, Ket_noi_MySql)
 cmd.ExecuteNonQuery()
 End Select 
 Ngatketnoi()
 End Sub
 Public Sub SuaGHICHU( ByVal GHICHU as System.String, ByVal IDCTPHIEUTHU As System.Int32 )
 Dim strSQL As String
 Moketnoi()
 select case ketnoi.MSsql 
 Case Class_KieuDL.Access
 strSQL = "Update CTPHIEUTHU Set GHICHU = ?  where IDCTPHIEUTHU= ? "
 Dim cmd As New OleDbCommand(strSQL, Ket_noi_access)
 cmd.Parameters.Add("@GHICHU", OleDbType.VarWChar)
 cmd.Parameters.Add("@IDCTPHIEUTHU", OleDbType.Integer)
 cmd.Parameters("@GHICHU").Value =  GHICHU
cmd.Parameters("@IDCTPHIEUTHU").Value =  IDCTPHIEUTHU
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.Sql,Class_KieuDL.sqlExpress 
 strSQL = "Update CTPHIEUTHU Set GHICHU = @GHICHU  where IDCTPHIEUTHU= @IDCTPHIEUTHU"
 Dim cmd As New sqlCommand(strSQL, Ket_noi_sql)
 cmd.Parameters.Add("@GHICHU", SqlDbType.NVarChar)
 cmd.Parameters.Add("@IDCTPHIEUTHU", SqlDbType.Int)
 cmd.Parameters("@GHICHU").Value =  GHICHU
cmd.Parameters("@IDCTPHIEUTHU").Value =  IDCTPHIEUTHU
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.SqlCe
 strSQL = "Update CTPHIEUTHU Set GHICHU =" & GHICHU & "  where IDCTPHIEUTHU=" & IDCTPHIEUTHU & ""
 Dim cmd As New SqlCeCommand(strSQL, Ket_noi_SqlCe)
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.Oracle
 strSQL = "Update CTPHIEUTHU Set GHICHU =" & GHICHU & "  where IDCTPHIEUTHU=" & IDCTPHIEUTHU & ""
 Dim cmd As New OracleCommand(strSQL, Ket_noi_Oracle)
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.MySql
 strSQL = "Update CTPHIEUTHU Set GHICHU =" & GHICHU & "  where IDCTPHIEUTHU=" & IDCTPHIEUTHU & ""
 Dim cmd As New MySqlCommand(strSQL, Ket_noi_MySql)
 cmd.ExecuteNonQuery()
 End Select 
 Ngatketnoi()
 End Sub
 Public Sub layBang()
 Chuoi_SQL = " Select * from CTPHIEUTHU
 Doc_bang()
 End Sub
 Public Sub layBangTheoIDCTPHIEUTHU(ByVal ARRAY1 As ArrayList)
 Dim DK As String = ""
 If ARRAY1.Count > 0 Then
 For I As Integer = 0 To ARRAY1.Count - 1
 DK = DK & IIf(DK <> "", " OR ", "") & "IDCTPHIEUTHU=" & ARRAY1.Item(i) & ""
 Next
 End If
 If DK <> "" Then DK = " WHERE " & DK 
 Chuoi_SQL = " Select * from CTPHIEUTHU" & DK
 Doc_bang()
 End Sub
 Public Sub layBangTheoIDCTPHIEUTHU(ByVal IDCTPHIEUTHU As System.Int32 )
 Chuoi_SQL = " Select * from CTPHIEUTHU where  IDCTPHIEUTHU = " & IDCTPHIEUTHU & ""
 Doc_bang()
 End Sub
 Public Sub XOABangTheoIDCTPHIEUTHU(ByVal IDCTPHIEUTHU As System.Int32)
 Dim strsql As String
 strSQL = "Delete From CTPHIEUTHU Where IDCTPHIEUTHU=" & IDCTPHIEUTHU & ""
 Thuc_hien_lenh(strsql)
 End Sub
 Public Sub layBangTheoMAPHIEUTHU(ByVal ARRAY1 As ArrayList)
 Dim DK As String = ""
 If ARRAY1.Count > 0 Then
 For I As Integer = 0 To ARRAY1.Count - 1
 DK = DK & IIf(DK <> "", " OR ", "") & "MAPHIEUTHU='" & ARRAY1.Item(i) & "'"
 Next
 End If
 If DK <> "" Then DK = " WHERE " & DK 
 Chuoi_SQL = " Select * from CTPHIEUTHU" & DK
 Doc_bang()
 End Sub
 Public Sub layBangTheoMAPHIEUTHU_like (ByVal MAPHIEUTHU As System.String )
 Chuoi_SQL = " Select * from CTPHIEUTHU where  MAPHIEUTHU  like '%" & MAPHIEUTHU & "%'"
 Doc_bang()
 End Sub
 Public Sub layBangTheoMAPHIEUTHU(ByVal MAPHIEUTHU As System.String )
 Chuoi_SQL = " Select * from CTPHIEUTHU where  MAPHIEUTHU = '" & MAPHIEUTHU & "'"
 Doc_bang()
 End Sub
 Public Sub XOABangTheoMAPHIEUTHU(ByVal MAPHIEUTHU As System.String)
 Dim strsql As String
 strSQL = "Delete From CTPHIEUTHU Where MAPHIEUTHU='" & MAPHIEUTHU & "'"
 Thuc_hien_lenh(strsql)
 End Sub
 Public Sub layBangTheoIDPHIEUTHU(ByVal ARRAY1 As ArrayList)
 Dim DK As String = ""
 If ARRAY1.Count > 0 Then
 For I As Integer = 0 To ARRAY1.Count - 1
 DK = DK & IIf(DK <> "", " OR ", "") & "IDPHIEUTHU=" & ARRAY1.Item(i) & ""
 Next
 End If
 If DK <> "" Then DK = " WHERE " & DK 
 Chuoi_SQL = " Select * from CTPHIEUTHU" & DK
 Doc_bang()
 End Sub
 Public Sub layBangTheoIDPHIEUTHU(ByVal IDPHIEUTHU As System.Int32 )
 Chuoi_SQL = " Select * from CTPHIEUTHU where  IDPHIEUTHU = " & IDPHIEUTHU & ""
 Doc_bang()
 End Sub
 Public Sub XOABangTheoIDPHIEUTHU(ByVal IDPHIEUTHU As System.Int32)
 Dim strsql As String
 strSQL = "Delete From CTPHIEUTHU Where IDPHIEUTHU=" & IDPHIEUTHU & ""
 Thuc_hien_lenh(strsql)
 End Sub
 Public Sub layBangTheoNGUOITHU(ByVal ARRAY1 As ArrayList)
 Dim DK As String = ""
 If ARRAY1.Count > 0 Then
 For I As Integer = 0 To ARRAY1.Count - 1
 DK = DK & IIf(DK <> "", " OR ", "") & "NGUOITHU=" & ARRAY1.Item(i) & ""
 Next
 End If
 If DK <> "" Then DK = " WHERE " & DK 
 Chuoi_SQL = " Select * from CTPHIEUTHU" & DK
 Doc_bang()
 End Sub
 Public Sub layBangTheoNGUOITHU(ByVal NGUOITHU As System.Int32 )
 Chuoi_SQL = " Select * from CTPHIEUTHU where  NGUOITHU = " & NGUOITHU & ""
 Doc_bang()
 End Sub
 Public Sub XOABangTheoNGUOITHU(ByVal NGUOITHU As System.Int32)
 Dim strsql As String
 strSQL = "Delete From CTPHIEUTHU Where NGUOITHU=" & NGUOITHU & ""
 Thuc_hien_lenh(strsql)
 End Sub
 Public Sub layBangTheoNGUOILAPPHIEU(ByVal ARRAY1 As ArrayList)
 Dim DK As String = ""
 If ARRAY1.Count > 0 Then
 For I As Integer = 0 To ARRAY1.Count - 1
 DK = DK & IIf(DK <> "", " OR ", "") & "NGUOILAPPHIEU=" & ARRAY1.Item(i) & ""
 Next
 End If
 If DK <> "" Then DK = " WHERE " & DK 
 Chuoi_SQL = " Select * from CTPHIEUTHU" & DK
 Doc_bang()
 End Sub
 Public Sub layBangTheoNGUOILAPPHIEU(ByVal NGUOILAPPHIEU As System.Int32 )
 Chuoi_SQL = " Select * from CTPHIEUTHU where  NGUOILAPPHIEU = " & NGUOILAPPHIEU & ""
 Doc_bang()
 End Sub
 Public Sub XOABangTheoNGUOILAPPHIEU(ByVal NGUOILAPPHIEU As System.Int32)
 Dim strsql As String
 strSQL = "Delete From CTPHIEUTHU Where NGUOILAPPHIEU=" & NGUOILAPPHIEU & ""
 Thuc_hien_lenh(strsql)
 End Sub
 Public Sub layBangTheoSOTIENTHU(ByVal ARRAY1 As ArrayList)
 Dim DK As String = ""
 If ARRAY1.Count > 0 Then
 For I As Integer = 0 To ARRAY1.Count - 1
 DK = DK & IIf(DK <> "", " OR ", "") & "SOTIENTHU=" & ARRAY1.Item(i) & ""
 Next
 End If
 If DK <> "" Then DK = " WHERE " & DK 
 Chuoi_SQL = " Select * from CTPHIEUTHU" & DK
 Doc_bang()
 End Sub
 Public Sub layBangTheoSOTIENTHU(ByVal SOTIENTHU As System.Int32 )
 Chuoi_SQL = " Select * from CTPHIEUTHU where  SOTIENTHU = " & SOTIENTHU & ""
 Doc_bang()
 End Sub
 Public Sub XOABangTheoSOTIENTHU(ByVal SOTIENTHU As System.Int32)
 Dim strsql As String
 strSQL = "Delete From CTPHIEUTHU Where SOTIENTHU=" & SOTIENTHU & ""
 Thuc_hien_lenh(strsql)
 End Sub
 Public Sub layBangTheoTRANGTHAI(ByVal ARRAY1 As ArrayList)
 Dim DK As String = ""
 If ARRAY1.Count > 0 Then
 For I As Integer = 0 To ARRAY1.Count - 1
 DK = DK & IIf(DK <> "", " OR ", "") & "TRANGTHAI=" & ARRAY1.Item(i) & ""
 Next
 End If
 If DK <> "" Then DK = " WHERE " & DK 
 Chuoi_SQL = " Select * from CTPHIEUTHU" & DK
 Doc_bang()
 End Sub
 Public Sub layBangTheoTRANGTHAI(ByVal TRANGTHAI As System.Int32 )
 Chuoi_SQL = " Select * from CTPHIEUTHU where  TRANGTHAI = " & TRANGTHAI & ""
 Doc_bang()
 End Sub
 Public Sub XOABangTheoTRANGTHAI(ByVal TRANGTHAI As System.Int32)
 Dim strsql As String
 strSQL = "Delete From CTPHIEUTHU Where TRANGTHAI=" & TRANGTHAI & ""
 Thuc_hien_lenh(strsql)
 End Sub
 Public Sub layBangTheoGHICHU(ByVal ARRAY1 As ArrayList)
 Dim DK As String = ""
 If ARRAY1.Count > 0 Then
 For I As Integer = 0 To ARRAY1.Count - 1
 DK = DK & IIf(DK <> "", " OR ", "") & "GHICHU='" & ARRAY1.Item(i) & "'"
 Next
 End If
 If DK <> "" Then DK = " WHERE " & DK 
 Chuoi_SQL = " Select * from CTPHIEUTHU" & DK
 Doc_bang()
 End Sub
 Public Sub layBangTheoGHICHU_like (ByVal GHICHU As System.String )
 Chuoi_SQL = " Select * from CTPHIEUTHU where  GHICHU  like '%" & GHICHU & "%'"
 Doc_bang()
 End Sub
 Public Sub layBangTheoGHICHU(ByVal GHICHU As System.String )
 Chuoi_SQL = " Select * from CTPHIEUTHU where  GHICHU = '" & GHICHU & "'"
 Doc_bang()
 End Sub
 Public Sub XOABangTheoGHICHU(ByVal GHICHU As System.String)
 Dim strsql As String
 strSQL = "Delete From CTPHIEUTHU Where GHICHU='" & GHICHU & "'"
 Thuc_hien_lenh(strsql)
 End Sub
 Public Sub layBangNhieuTable
 Chuoi_SQL = " Select IDCTPHIEUTHU ,MAPHIEUTHU ,IDPHIEUTHU ,NGUOITHU ,NGUOILAPPHIEU ,SOTIENTHU ,TRANGTHAI ,GHICHU  from CTPHIEUTHU"
 Doc_bang()
 End sub
Public Sub TaoTable()
Dim strsql As String
strsql = ""
Select Case ketnoi.MsSql
Case Class_KieuDL.Access 
Case Class_KieuDL.Sql, Class_KieuDL.sqlExpress
strsql = ""
Case Class_KieuDL.SqlCe
strsql = ""
Case Class_KieuDL.Oracle
strsql = ""
Case else 
strsql = ""
End Select
Thuc_hien_lenh(strsql)
End Sub
 End Class

